import { ITable } from "@/components/Table/src/type"
import { IForm } from "@/components/Form/src/type"
export const useTableConfig = (): ITable => {
  return {
    tableData: [
      { username: 'Ares', password: '123456', role: '管理员', createAt: '2022-10-12 17:22' },
      { username: '风再起时', password: '123456', role: '用户', createAt: '2022-10-12 17:22' },
      { username: 'Harden', password: '123456', role: '用户', createAt: '2022-10-12 17:22' },
      { username: 'Pingk', password: '123456', role: '用户', createAt: '2022-10-12 17:22' },
      { username: 'A', password: '123456', role: '用户', createAt: '2022-10-12 17:22' },
    ],
    columnConfig: [
      { prop: 'username', label: '用户名', 'min-width': '100', field: 'username' },
      { prop: 'password', label: '密码', 'min-width': '100', field: 'password' },
      { prop: 'role', label: '角色', 'min-width': '100', field: 'role' },
      { prop: 'createAt', label: '创建时间', 'min-width': '180', field: 'createAt' },
    ],
    showIndexColumn: true,
    paginationInfo: {
      currentPage: 1,
      pageSize: 10,
      total: 10
    }
  }
}

export const useFormConfig = (): IForm => {
  return {
    labelWidth: 80,
    rules: {
      username: [
        { required: true, message: '请输入用户名' },
        { min: 1, max: 12, message: '用户名长度应该为1~12位' }
      ],
      password: [
        { required: true, message: '请输入密码' },
        { min: 6, max: 20, message: '密码长度应该为6~20位' }
      ],
      role: [
        { required: true, message: '请选择角色' }
      ]
    },
    formItems: [
      {
        type: 'input',
        field: 'username',
        prop: 'username',
        required: true,
        label: '用户名'
      },
      {
        type: 'input',
        field: 'password',
        prop: 'password',
        required: true,
        label: '密码',
        otherOptions: {
          type: 'password',
          'show-password': true
        }
      },
      {
        type: 'select',
        field: 'role',
        prop: 'role',
        required: true,
        label: '角色名称',
        options: [
          { label: '管理员', value: 1 },
          { label: '用户', value: 2 },
        ]
      }
    ],
    btns: [
      { name: '提交', action: 'submit', otherOptions: { type: 'primary', plain: 'plain' }},
      { name: '取消', action: 'cancel', otherOptions: { plain: 'plain' } }
    ]
  }
}
